package cn.iocoder.yudao.framework.business.basic.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 排序类型的枚举值
 *
 * @author 芋道源码
 */
@Getter
@AllArgsConstructor
public enum SortTypeEnum implements EnumCodable {

    UNKNOWN("", "默认"),
    RANDOM("random", "随机"),
    ID("id", "时间"),
    PRICE("price", "价格"),
    RECOMMEND("recommend", "推荐"),
    SALES_COUNT("sales_count", "销量"),
    BROWSE_COUNT("browse_count", "人气"),
    DISTANCE("distance", "距离"),
    SCORE("score", "评分"),
    ;

    private final String code;
    private final String name;

    public static SortTypeEnum codeOf(String code) {
        for (SortTypeEnum item : values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return UNKNOWN;
    }

}
